package cn.iocoder.yudao.module.system.controller.admin.teacherdashboard.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

@Schema(description = "管理后台 - 优化的教师看板数据 Response VO")
@Data
public class OptimizedTeacherDashboardRespVO {

    @Schema(description = "班级概况")
    private ClassOverview classOverview;

    @Schema(description = "考试表现")
    private ExamPerformance examPerformance;

    @Schema(description = "升学预测")
    private AdmissionForecast admissionForecast;

    @Schema(description = "重点关注学生")
    private List<FocusStudent> focusStudents;

    @Schema(description = "班级对比")
    private ClassComparison classComparison;

    @Schema(description = "教学建议")
    private List<TeachingSuggestion> teachingSuggestions;

    /**
     * 班级概况 - 教师最关心的基本信息
     */
    @Data
    public static class ClassOverview {
        @Schema(description = "班级ID", example = "1")
        private Long classId;

        @Schema(description = "班级名称", example = "高三(1)班")
        private String className;

        @Schema(description = "年级", example = "高三")
        private String grade;

        @Schema(description = "学生总数", example = "45")
        private Integer totalStudents;

        @Schema(description = "班主任姓名", example = "张老师")
        private String teacherName;

        @Schema(description = "班级类型", example = "理科重点班")
        private String classType;

        @Schema(description = "班级目标", example = "一本上线率80%")
        private String classTarget;
    }

    /**
     * 考试表现 - 最新考试的核心数据
     */
    @Data
    public static class ExamPerformance {
        @Schema(description = "考试名称", example = "2024年高三上学期期中考试")
        private String examName;

        @Schema(description = "考试时间", example = "2024-01-15T08:30:00")
        private LocalDateTime examDate;

        @Schema(description = "参考人数", example = "44")
        private Integer participantCount;

        @Schema(description = "班级平均分", example = "620.5")
        private BigDecimal classAvgScore;

        @Schema(description = "班级最高分", example = "684.5")
        private BigDecimal classMaxScore;

        @Schema(description = "年级平均分", example = "580.5")
        private BigDecimal gradeAvgScore;

        @Schema(description = "超年级平均分", example = "40.0")
        private BigDecimal aboveGradeAvg;

        @Schema(description = "班级在年级排名", example = "2")
        private Integer classRankInGrade;

        @Schema(description = "年级班级总数", example = "8")
        private Integer totalClassesInGrade;

        @Schema(description = "各科平均分")
        private List<SubjectScore> subjectScores;

        @Schema(description = "分数段分布")
        private List<ScoreRange> scoreRanges;
    }

    /**
     * 科目成绩
     */
    @Data
    public static class SubjectScore {
        @Schema(description = "科目名称", example = "数学")
        private String subjectName;

        @Schema(description = "班级平均分", example = "128.5")
        private BigDecimal avgScore;

        @Schema(description = "满分", example = "150.0")
        private BigDecimal fullScore;

        @Schema(description = "及格率", example = "95.6")
        private BigDecimal passRate;

        @Schema(description = "年级排名", example = "1")
        private Integer gradeRank;

        @Schema(description = "表现评价", example = "优秀")
        private String performance; // 优秀、良好、一般、需改进
    }

    /**
     * 分数段分布
     */
    @Data
    public static class ScoreRange {
        @Schema(description = "分数段", example = "650-700")
        private String range;

        @Schema(description = "人数", example = "12")
        private Integer count;

        @Schema(description = "占比", example = "26.7")
        private BigDecimal percentage;

        @Schema(description = "等级", example = "优秀")
        private String level;
    }

    /**
     * 升学预测 - 教师最关心的升学数据
     */
    @Data
    public static class AdmissionForecast {
        @Schema(description = "985院校预测上线人数", example = "8")
        private Integer predicted985Count;

        @Schema(description = "985院校预测上线率", example = "17.8")
        private BigDecimal predicted985Rate;

        @Schema(description = "211院校预测上线人数", example = "15")
        private Integer predicted211Count;

        @Schema(description = "211院校预测上线率", example = "33.3")
        private BigDecimal predicted211Rate;

        @Schema(description = "一本线预测上线人数", example = "35")
        private Integer predictedFirstTierCount;

        @Schema(description = "一本线预测上线率", example = "77.8")
        private BigDecimal predictedFirstTierRate;

        @Schema(description = "目标达成情况")
        private TargetAchievement targetAchievement;

        @Schema(description = "与上次考试对比")
        private ForecastComparison comparison;
    }

    /**
     * 目标达成情况
     */
    @Data
    public static class TargetAchievement {
        @Schema(description = "目标描述", example = "一本上线率80%")
        private String targetDescription;

        @Schema(description = "目标人数", example = "36")
        private Integer targetCount;

        @Schema(description = "当前预测人数", example = "35")
        private Integer currentCount;

        @Schema(description = "完成率", example = "97.2")
        private BigDecimal achievementRate;

        @Schema(description = "达成状态", example = "接近达成")
        private String status; // 已达成、接近达成、需努力、差距较大
    }

    /**
     * 预测对比
     */
    @Data
    public static class ForecastComparison {
        @Schema(description = "一本上线率变化", example = "5.6")
        private BigDecimal firstTierRateChange;

        @Schema(description = "985上线率变化", example = "2.2")
        private BigDecimal rate985Change;

        @Schema(description = "211上线率变化", example = "4.4")
        private BigDecimal rate211Change;

        @Schema(description = "变化趋势", example = "上升")
        private String trend; // 上升、下降、稳定
    }

    /**
     * 重点关注学生 - 教师需要特别关注的学生
     */
    @Data
    public static class FocusStudent {
        @Schema(description = "学生ID", example = "1001")
        private Long studentId;

        @Schema(description = "学生姓名", example = "张三")
        private String studentName;

        @Schema(description = "学号", example = "G3C1001")
        private String studentNo;

        @Schema(description = "关注类型", example = "临界985")
        private String focusType; // 临界985、临界211、临界一本、成绩下滑、进步显著

        @Schema(description = "当前总分", example = "678")
        private BigDecimal currentScore;

        @Schema(description = "目标分数", example = "680")
        private BigDecimal targetScore;

        @Schema(description = "分数差距", example = "2")
        private BigDecimal scoreDiff;

        @Schema(description = "班级排名", example = "3")
        private Integer classRank;

        @Schema(description = "年级排名", example = "8")
        private Integer gradeRank;

        @Schema(description = "关注原因", example = "距离985线仅差2分，有冲击可能")
        private String focusReason;

        @Schema(description = "建议措施", example = "加强数学薄弱环节")
        private String suggestion;
    }

    /**
     * 班级对比 - 与其他班级的简单对比
     */
    @Data
    public static class ClassComparison {
        @Schema(description = "年级排名", example = "2")
        private Integer gradeRank;

        @Schema(description = "年级总班级数", example = "8")
        private Integer totalClasses;

        @Schema(description = "平均分排名", example = "2")
        private Integer avgScoreRank;

        @Schema(description = "一本上线率排名", example = "1")
        private Integer firstTierRateRank;

        @Schema(description = "与第一名差距", example = "5.2")
        private BigDecimal gapToFirst;

        @Schema(description = "优势科目")
        private List<String> advantageSubjects;

        @Schema(description = "薄弱科目")
        private List<String> weakSubjects;
    }

    /**
     * 教学建议 - 基于数据分析的教学建议
     */
    @Data
    public static class TeachingSuggestion {
        @Schema(description = "建议类型", example = "科目提升")
        private String suggestionType; // 科目提升、学生关注、目标调整、教学策略

        @Schema(description = "优先级", example = "高")
        private String priority; // 高、中、低

        @Schema(description = "建议内容", example = "数学科目需要加强基础训练")
        private String content;

        @Schema(description = "涉及学生数", example = "12")
        private Integer affectedStudentCount;

        @Schema(description = "预期效果", example = "预计可提升班级平均分3-5分")
        private String expectedEffect;
    }
}